﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.project
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int projectId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(projectId);
				}
			}
		}
			
	private void ShowInfo(int projectId)
	{
		Maticsoft.BLL.project bll=new Maticsoft.BLL.project();
		Maticsoft.Model.project model=bll.GetModel(projectId);
		this.lblprojectId.Text=model.projectId.ToString();
		this.txtproid.Text=model.proid;
		this.txtprojectName.Text=model.projectName;
		this.txtbeComplatedTime.Text=model.beComplatedTime.ToString();
		this.txtprojectTypeId.Text=model.projectTypeId.ToString();
		this.txtstatus.Text=model.status;
		this.txtlevelType.Text=model.levelType;
		this.chkisComplated.Checked=model.isComplated;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtproid.Text.Trim().Length==0)
			{
				strErr+="proid不能为空！\\n";	
			}
			if(this.txtprojectName.Text.Trim().Length==0)
			{
				strErr+="projectName不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtbeComplatedTime.Text))
			{
				strErr+="beComplatedTime格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtprojectTypeId.Text))
			{
				strErr+="projectTypeId格式错误！\\n";	
			}
			if(this.txtstatus.Text.Trim().Length==0)
			{
				strErr+="status不能为空！\\n";	
			}
			if(this.txtlevelType.Text.Trim().Length==0)
			{
				strErr+="levelType不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int projectId=int.Parse(this.lblprojectId.Text);
			string proid=this.txtproid.Text;
			string projectName=this.txtprojectName.Text;
			DateTime beComplatedTime=DateTime.Parse(this.txtbeComplatedTime.Text);
			int projectTypeId=int.Parse(this.txtprojectTypeId.Text);
			string status=this.txtstatus.Text;
			string levelType=this.txtlevelType.Text;
			bool isComplated=this.chkisComplated.Checked;


			Maticsoft.Model.project model=new Maticsoft.Model.project();
			model.projectId=projectId;
			model.proid=proid;
			model.projectName=projectName;
			model.beComplatedTime=beComplatedTime;
			model.projectTypeId=projectTypeId;
			model.status=status;
			model.levelType=levelType;
			model.isComplated=isComplated;

			Maticsoft.BLL.project bll=new Maticsoft.BLL.project();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","List.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
